Skip to content

Extend CacheRuntime phase 2.5: transform Cache Runtime Spec into pods spec#5888

Merged
xliuqq merged 9 commits into
fluid-cloudnative:masterfrom
xliuqq:transform
May 27, 2026
Merged

Extend CacheRuntime phase 2.5: transform Cache Runtime Spec into pods spec#5888
xliuqq merged 9 commits into
fluid-cloudnative:masterfrom
xliuqq:transform

Conversation

@xliuqq
Copy link
Copy Markdown
Collaborator

@xliuqq xliuqq commented May 17, 2026

Ⅰ. Describe what this PR does

transform Cache Runtime Spec into master/worker/client pods spec

Ⅱ. Does this pull request fix one issue?

part of #5412 and fix #5877

Ⅲ. List the added test cases (unit test/integration test) if any, please explain if no tests are needed.

unit test

Ⅳ. Describe how to verify it

Ⅴ. Special notes for reviews

RuntimeTieredStore for worker/client and storage for master(ha) not yet resolved

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request refactors the CacheEngine component transformation and status update logic to be more modular and efficient. It introduces lightweight status tracking using ComponentIdentity and consolidates volume and pod template transformations into shared helper functions. Additionally, it replaces hardcoded labels with constants and significantly expands test coverage. Feedback identifies a bug in worker affinity construction where existing node affinity preferences are overwritten, and a potential issue with duplicate volume names in pod specs due to incomplete tracking of previously added volumes.

Comment thread pkg/ddc/cache/engine/transform_worker.go
Comment thread pkg/ddc/cache/engine/transform_volumes.go
@codecov
Copy link
Copy Markdown

codecov Bot commented May 17, 2026

Codecov Report

❌ Patch coverage is 80.39216% with 90 lines in your changes missing coverage. Please review.
✅ Project coverage is 63.35%. Comparing base (b0222b2) to head (3b421ec).
⚠️ Report is 5 commits behind head on master.

Files with missing lines Patch % Lines
pkg/ddc/cache/engine/transform_volumes.go 60.18% 40 Missing and 3 partials ⚠️
pkg/ddc/cache/engine/transform_common.go 65.62% 22 Missing and 11 partials ⚠️
pkg/ddc/cache/engine/setup.go 0.00% 5 Missing ⚠️
pkg/ddc/cache/engine/transform_client.go 84.21% 2 Missing and 1 partial ⚠️
pkg/ddc/cache/component/daemonset_manager.go 60.00% 2 Missing ⚠️
pkg/ddc/cache/component/statefulset_manager.go 60.00% 2 Missing ⚠️
pkg/ddc/cache/engine/transform_worker.go 98.41% 1 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #5888      +/-   ##
==========================================
+ Coverage   62.59%   63.35%   +0.76%     
==========================================
  Files         480      481       +1     
  Lines       32801    33070     +269     
==========================================
+ Hits        20533    20953     +420     
+ Misses      10633    10442     -191     
- Partials     1635     1675      +40     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR implements the second phase (2.5) of CacheRuntime spec→pod transformation for master, worker and client components. It introduces dedicated transformation helpers (initComponentValue, transformComponentPodTemplate, transformVolumes, buildWorkerAffinity), splits the heavy transform() from a lightweight getRuntimeStatusValue() used by Sync/Setup for status-only updates (addressing #5877), and refactors ComponentManager.ConstructComponentStatus/GetNodeAffinity to take a minimal ComponentIdentity plus a new CacheRuntimeStatusValue/ComponentStatusInfo types instead of the full CacheRuntimeComponentValue. It also factors out hard-coded label keys (fluid.io/dataset[-placement], kubernetes.io/hostname) into common constants.

Changes:

  • Refactor cache runtime transform into reusable helpers for pod template, volumes, and worker affinity, with deep-copying of the runtime class template.
  • Introduce lightweight CacheRuntimeStatusValue/ComponentStatusInfo/ComponentIdentity types and switch Sync/Setup status updates to them.
  • Replace string-literal label keys with common.LabelAnnotationDataset[Placement] / common.K8sNodeNameLabelKey in jindo, ctrl/affinity, and cache transforms.

Reviewed changes

Copilot reviewed 32 out of 32 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
pkg/common/cacheruntime.go Adds CacheRuntimeStatusValue, ComponentIdentity, ComponentStatusInfo, MatchLabels field; drops RuntimeIdentity from CacheRuntimeValue.
pkg/common/label.go Adds LabelAnnotationDatasetPlacement constant.
pkg/ctrl/affinity.go, pkg/ctrl/affinity_test.go Replace hardcoded label/topology strings with common constants.
pkg/ddc/jindo/worker.go, worker_test.go Same constants migration for Jindo.
pkg/ddc/cache/component/component_manager.go Interface changes: status/affinity now take ComponentIdentity.
pkg/ddc/cache/component/statefulset_manager.go Switch status/affinity functions to identity argument.
pkg/ddc/cache/component/daemonset_manager.go Same, plus consumes component.MatchLabels for selector.
pkg/ddc/cache/component/component_test.go Updates tests for new identity-based API.
pkg/ddc/cache/engine/transform.go Splits transform; adds getRuntimeStatusValue; removes addCommonConfigForComponent.
pkg/ddc/cache/engine/transform_common.go New: initComponentValue and transformComponentPodTemplate (image, env, nodeSelector, tolerations, etc.).
pkg/ddc/cache/engine/transform_master.go / _client.go / _worker.go Re-implemented using new helpers; worker adds in-engine affinity & MatchLabels.
pkg/ddc/cache/engine/transform_volumes.go Consolidated volume transform: runtime config, extra CMs, runtime spec volumes, encrypt options.
pkg/ddc/cache/engine/transform_*_test.go, transform_test.go, sync_test.go, setup_test.go, component_setup_test.go New/updated unit tests.
pkg/ddc/cache/engine/sync.go Use lightweight getRuntimeStatusValue for Sync.
pkg/ddc/cache/engine/setup.go Use getRuntimeStatusValue before CheckAndUpdateRuntimeStatus.
pkg/ddc/cache/engine/status.go, status_test.go Status setters use ComponentStatusInfo.
pkg/ddc/cache/engine/master.go, worker.go, client.go Build ComponentIdentity from component value before status query.
test/gha-e2e/curvine/cacheruntime.yaml Removes unused client volumeMounts/volumes example block.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread pkg/ddc/cache/engine/transform_worker.go Outdated
Comment thread pkg/ddc/cache/engine/transform_volumes.go Outdated
Comment thread pkg/ddc/cache/engine/transform_volumes.go
Comment thread pkg/ddc/cache/engine/sync.go Outdated
Comment thread pkg/ddc/cache/engine/setup_test.go
Comment thread pkg/ddc/cache/engine/transform_master.go Outdated
Comment thread pkg/ddc/cache/engine/transform_worker.go Outdated
Comment thread pkg/ddc/cache/engine/sync.go Outdated
Comment thread pkg/ddc/cache/engine/transform_worker.go Outdated
xliuqq added 6 commits May 20, 2026 19:25
Signed-off-by: xliuqq <xlzq1992@gmail.com>

fix affinity
Signed-off-by: xliuqq <xlzq1992@gmail.com>
Signed-off-by: xliuqq <xlzq1992@gmail.com>
Signed-off-by: xliuqq <xlzq1992@gmail.com>
Signed-off-by: xliuqq <xlzq1992@gmail.com>
Signed-off-by: xliuqq <xlzq1992@gmail.com>
Signed-off-by: xliuqq <xlzq1992@gmail.com>
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 34 out of 34 changed files in this pull request and generated 1 comment.

Comments suppressed due to low confidence (1)

pkg/ddc/cache/engine/transform_volumes.go:204

  • transformRuntimeSpecVolumes appends all runtime-provided volumeMounts directly to containers[0].VolumeMounts without dedup/override. If the runtimeClass template already defines a mount with the same Name or MountPath, this can produce duplicate mounts and an invalid PodSpec. Prefer using utils.AppendOrOverrideVolumeMounts (or similar dedup logic) when applying runtime Spec volumeMounts.
	// First pass: identify which volumes are referenced by volumeMounts and add volumeMounts to container
	referencedVolumeMap := make(map[string]bool)
	for _, volumeMount := range volumeMounts {
		referencedVolumeMap[volumeMount.Name] = true
		podSpec.Containers[0].VolumeMounts = append(
			podSpec.Containers[0].VolumeMounts, volumeMount,
		)
	}

Comment on lines +63 to +88
func (e *CacheEngine) applyRuntimeConfigVolume(podSpec *corev1.PodSpec, commonConfig *CacheRuntimeComponentCommonConfig) {
if commonConfig == nil || commonConfig.RuntimeConfigs.RuntimeConfigVolume.Name == "" {
return
}

// Add runtime config volume
podSpec.Volumes = append(
podSpec.Volumes,
commonConfig.RuntimeConfigs.RuntimeConfigVolume,
)

// Add runtime config volume mount to init container if exists
if len(podSpec.InitContainers) > 0 {
podSpec.InitContainers[0].VolumeMounts = append(
podSpec.InitContainers[0].VolumeMounts,
commonConfig.RuntimeConfigs.RuntimeConfigVolumeMount,
)
}

// Add runtime config volume mount to main container
if len(podSpec.Containers) > 0 {
podSpec.Containers[0].VolumeMounts = append(
podSpec.Containers[0].VolumeMounts,
commonConfig.RuntimeConfigs.RuntimeConfigVolumeMount,
)
}
Copy link
Copy Markdown
Collaborator

@cheyang cheyang left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code review by AI agent

Signed-off-by: xliuqq <xlzq1992@gmail.com>
@xliuqq xliuqq requested a review from cheyang May 21, 2026 12:48
Comment thread pkg/ddc/cache/engine/transform_worker.go Outdated
Signed-off-by: xliuqq <xlzq1992@gmail.com>
@sonarqubecloud
Copy link
Copy Markdown

Copy link
Copy Markdown
Collaborator

@cheyang cheyang left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. The Cartesian product fix for NodeSelectorTerms correctly implements AND semantics. MatchLabels and GetDatasetId issues are also resolved. A couple of non-blocking suggestions: (1) consider handling MatchFields in the Cartesian product merge, and (2) add a test case for multiple NodeSelectorTerms on both sides.

@cheyang
Copy link
Copy Markdown
Collaborator

cheyang commented May 27, 2026

/lgtm

@cheyang
Copy link
Copy Markdown
Collaborator

cheyang commented May 27, 2026

/approve

@fluid-e2e-bot fluid-e2e-bot Bot added the lgtm label May 27, 2026
@fluid-e2e-bot
Copy link
Copy Markdown

fluid-e2e-bot Bot commented May 27, 2026

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: cheyang

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@xliuqq xliuqq merged commit 28b7b87 into fluid-cloudnative:master May 27, 2026
23 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[CacheRuntime] Sync cycle avoid a full value tranform computation

3 participants